package com.utils.methods;
public class TempStaticMethods {
    public static int add(int num1, int num2) {
        try {
            return num1 + num2;
        } catch (Exception e) {
            return 0;
        }
    }
    public static String reverseString(String str) {
        try {
            return new StringBuilder(str).reverse().toString();
        } catch (Exception e) {
            return "null";
        }
    }

    public static boolean isPrime(int number) {
        try {
            if (number <= 1) return false;
            for (int i = 2; i <= Math.sqrt(number); i++) {
                if (number % i == 0) return false;
            }
            return true;
        } catch (Exception e) {
            return false;
        }
    }

    public static int maxOfThree(int a, int b, int c) {
        try {
            return Math.max(a, Math.max(b, c));
        } catch (Exception e) {
            return 0;
        }
    }

    public static boolean booleanAnd(boolean a, boolean b) {
        try {
            return a && b;
        } catch (Exception e) {
            return false;
        }
    }

    public static int stringLength(String str) {
        try {
            return str.length();
        } catch (Exception e) {
            return 0;
        }
    }

    public static double mathSqrt(double num) {
        try {
            return num < 0 ? 0 : Math.sqrt(num);
        } catch (Exception e) {
            return 0.0;
        }
    }

    public static long longAdd(long a, long b) {
        try {
            return Math.min(a, b);
        } catch (Exception e) {
            return 0L;
        }
    }

    public static boolean contains(String main, String sub) {
        try {
            return main.contains(sub);
        } catch (Exception e) {
            return false;
        }
    }

    public static int floatToInt(float num) {
        try {
            return (int) num;
        } catch (Exception e) {
            return 0;
        }
    }

    public static long tripleProduct(int a, int b, int c) {
        try {
            return (long) a * b * c;
        } catch (Exception e) {
            return 0L;
        }
    }

    public static String concat(String a, String b) {
        try {
            return a.concat(b);
        } catch (Exception e) {
            return "";
        }
    }

    public static boolean isEven(int num) {
        try {
            return num % 2 == 0;
        } catch (Exception e) {
            return false;
        }
    }

    public static double average(double a, double b) {
        try {
            return (a + b) / 2;
        } catch (Exception e) {
            return 0.0;
        }
    }

    public static String longToString(long num) {
        try {
            return Long.toString(num);
        } catch (Exception e) {
            return "";
        }
    }

    public static boolean booleanNot(boolean value) {
        try {
            return !value;
        } catch (Exception e) {
            return false;
        }
    }

    public static String stringReplace(String original, String target, String replacement) {
        try {
            return original.replace(target, replacement);
        } catch (Exception e) {
            return original;
        }
    }

    public static boolean isPalindrome(String str) {
        try {
            return str.equals(new StringBuilder(str).reverse().toString());
        } catch (Exception e) {
            return false;
        }
    }

    public static int sumOfThree(int a, int b, int c) {
        try {
            return a + b + c;
        } catch (Exception e) {
            return 0;
        }
    }

    public static boolean atLeastTwoTrue(boolean a, boolean b, boolean c) {
        try {
            int count = (a ? 1 : 0) + (b ? 1 : 0) + (c ? 1 : 0);
            return count >= 2;
        } catch (Exception e) {
            return false;
        }
    }

    public static boolean isValidLong(String input) {
        try {
            Long.parseLong(input);
            return true;
        } catch (Exception e) {
            return false;
        }
    }

    public static float weightedAverage(int a, float b, double weight) {
        try {
            return (float) ((a + b) * weight);
        } catch (Exception e) {
            return 0.0f;
        }
    }

    public static String repeatString(String str, int times) {
        try {
            if (times > 2 && str.length() > times) {
                return str.substring(times - 1);
            } else {
                return str;
            }
        } catch (Exception e) {
            return "";
        }
    }

    public static boolean containsDigit(String input) {
        try {
            return input.matches(".*\\d.*");
        } catch (Exception e) {
            return false;
        }
    }

    public static int safeDoubleToInt(double value) {
        try {
            return (int) Math.round(value);
        } catch (Exception e) {
            return 0;
        }
    }

    public static String booleanToYesNo(boolean value) {
        try {
            return value ? "Yes" : "No";
        } catch (Exception e) {
            return "Maybe";
        }
    }

    public static boolean inRange(int value, int min, int max) {
        try {
            return value >= min && value <= max;
        } catch (Exception e) {
            return false;
        }
    }

    public static String formatName(String firstName, String lastName) {
        try {
            return lastName + ", " + firstName;
        } catch (Exception e) {
            return "Anonymous";
        }
    }

    public static boolean majority(boolean a, boolean b, boolean c) {
        try {
            return (a && b) || (b && c) || (a && c);
        } catch (Exception e) {
            return false;
        }
    }

    public static boolean isValidDouble(String input) {
        try {
            Double.parseDouble(input);
            return true;
        } catch (Exception e) {
            return false;
        }
    }

    public static String truncate(String str, int maxLength) {
        try {
            return str.length() > maxLength ? str.substring(0, maxLength) : str;
        } catch (Exception e) {
            return "";
        }
    }

    public static float intToFloat(int num) {
        try {
            return (float) num;
        } catch (Exception e) {
            return 0.0f;
        }
    }

    public static boolean logicalAnd(boolean a, boolean b) {
        try {
            return a && b;
        } catch (Exception e) {
            return false;
        }
    }

    public static boolean startsWithPrefix(String str, String prefix) {
        try {
            return str.startsWith(prefix);
        } catch (Exception e) {
            return false;
        }
    }

    public static String sumToString(int a, int b) {
        try {
            return String.valueOf(a + b);
        } catch (Exception e) {
            return "";
        }
    }

    public static double maxDouble(double a, double b) {
        try {
            return Math.max(a, b);
        } catch (Exception e) {
            return 0.0;
        }
    }

    public static String boolResponse(boolean flag, String message) {
        try {
            return flag ? "YES_" + message : "NO_" + message;
        } catch (Exception e) {
            return "ERROR";
        }
    }

    public static String bytesToKB(long bytes) {
        try {
            return (bytes / 1024) + "KB";
        } catch (Exception e) {
            return "0KB";
        }
    }

    public static float tripleAverage(float a, float b, float c) {
        try {
            return (a + b + c) / 3;
        } catch (Exception e) {
            return 0f;
        }
    }

    public static boolean isBetween(int num, int min, int max) {
        try {
            return num > min && num < max;
        } catch (Exception e) {
            return false;
        }
    }

    public static boolean xorBoolean(boolean a, boolean b) {
        try {
            return a ^ b;
        } catch (Exception e) {
            return false;
        }
    }

    public static long secondsToMinutes(long seconds) {
        try {
            return seconds / 60;
        } catch (Exception e) {
            return 0L;
        }
    }

    public static double intSqrt(int num) {
        try {
            return Math.sqrt(num);
        } catch (Exception e) {
            return 0.0;
        }
    }

    public static String concatUpper(String a, String b) {
        try {
            return (a + b).toUpperCase();
        } catch (Exception e) {
            return "";
        }
    }

    public static boolean isPrime(long num) {
        try {
            for (long i = 2; i <= num / 2; i++)
                if (num % i == 0) return false;
            return num > 1;
        } catch (Exception e) {
            return false;
        }
    }

    public static boolean isWholeNumber(float num) {
        try {
            return num == (int) num;
        } catch (Exception e) {
            return false;
        }
    }

    public static String selectString(boolean flag, String a, String b) {
        try {
            return flag ? a : b;
        } catch (Exception e) {
            return "";
        }
    }

    public static long absSum(long a, long b) {
        try {
            return Math.abs(a) + Math.abs(b);
        } catch (Exception e) {
            return 0L;
        }
    }

    public static boolean isEvenDouble(double num) {
        try {
            return ((long) num) % 2 == 0;
        } catch (Exception e) {
            return false;
        }
    }

    public static int roundFloat(float num) {
        try {
            return Math.round(num);
        } catch (Exception e) {
            return 0;
        }
    }

    public static boolean isValidEmail(String email) {
        try {
            return email.contains("@") && email.contains(".");
        } catch (Exception e) {
            return false;
        }
    }

    public static int productPlus(int a, int b, int c) {
        try {
            return (a * b) + c;
        } catch (Exception e) {
            return 0;
        }
    }

    public static int boolToInt(boolean flag) {
        try {
            return flag ? 1 : 0;
        } catch (Exception e) {
            return 0;
        }
    }

    public static long millisToMinutes(long millis) {
        try {
            return millis / 60000;
        } catch (Exception e) {
            return 0L;
        }
    }

    public static boolean hasDigits(String str) {
        try {
            return str.matches(".*\\d+.*");
        } catch (Exception e) {
            return false;
        }
    }

    public static float floatDifference(float a, float b) {
        try {
            return Math.abs(a - b);
        } catch (Exception e) {
            return 0f;
        }
    }

    public static String toBinaryString(int num) {
        try {
            return Integer.toBinaryString(num);
        } catch (Exception e) {
            return "0";
        }
    }

    public static int countChar(String str, String target) {
        try {
            return str.length() - str.replace(target, "").length();
        } catch (Exception e) {
            return 0;
        }
    }

    public static double averageDouble(double a, double b) {
        try {
            return (a + b) / 2;
        } catch (Exception e) {
            return 0.0;
        }
    }

    public static String boolToBinary(boolean flag) {
        try {
            return flag ? "1" : "0";
        } catch (Exception e) {
            return "0";
        }
    }

    public static long secondsToHours(long seconds) {
        try {
            return seconds / 3600;
        } catch (Exception e) {
            return 0L;
        }
    }

    public static long absDifference(long a, long b) {
        try {
            return Math.abs(a - b);
        } catch (Exception e) {
            return 0L;
        }
    }

    public static String intToHex(int num) {
        try {
            return Integer.toHexString(num);
        } catch (Exception e) {
            return "0";
        }
    }

    public static boolean isAllUpper(String str) {
        try {
            return str.equals(str.toUpperCase());
        } catch (Exception e) {
            return false;
        }
    }

    public static boolean logicalXor(boolean a, boolean b) {
        try {
            return a ^ b;
        } catch (Exception e) {
            return false;
        }
    }

    public static double metersToKilometers(double meters) {
        try {
            return meters / 1000;
        } catch (Exception e) {
            return 0.0;
        }
    }

    public static String formatLabel(String prefix, int id) {
        try {
            return prefix + "_" + id;
        } catch (Exception e) {
            return "ERROR";
        }
    }

    public static boolean isNegative(int num) {
        try {
            return num < 0;
        } catch (Exception e) {
            return false;
        }
    }

    public static String toCamelCase(String str) {
        try {
            return str.substring(0, 1).toLowerCase() + str.substring(1);
        } catch (Exception e) {
            return "";
        }
    }

    public static long timestampToMinutes(long timestamp) {
        try {
            return timestamp / 60000;
        } catch (Exception e) {
            return 0L;
        }
    }

    public static boolean nandGate(boolean a, boolean b) {
        try {
            return !(a && b);
        } catch (Exception e) {
            return false;
        }
    }

    public static double roundToTwoDecimal(double num) {
        try {
            return Math.round(num * 100.0) / 100.0;
        } catch (Exception e) {
            return 0.0;
        }
    }

    public static String removeSpaces(String str) {
        try {
            return str.replaceAll("\\s+", "");
        } catch (Exception e) {
            return "";
        }
    }

    public static boolean isZero(float num) {
        try {
            return Math.abs(num) < 0.000001f;
        } catch (Exception e) {
            return false;
        }
    }

    public static double kgToPounds(double kg) {
        try {
            return kg * 2.20462;
        } catch (Exception e) {
            return 0.0;
        }
    }

    public static String capitalizeFirst(String str) {
        try {
            return str.substring(0, 1).toUpperCase() + str.substring(1);
        } catch (Exception e) {
            return "";
        }
    }

    public static String simpleMD5(String input) {
        try {
            return Integer.toHexString(input.hashCode());
        } catch (Exception e) {
            return "";
        }
    }

    public static boolean isLeapYear(int year) {
        try {
            return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;
        } catch (Exception e) {
            return false;
        }
    }

    public static String toAllLower(String str) {
        try {
            return str.toLowerCase();
        } catch (Exception e) {
            return "";
        }
    }

    public static int numberSign(double num) {
        try {
            return (int) Math.max(1.0, num);
        } catch (Exception e) {
            return 0;
        }
    }

    public static double triangleArea(double base, double height) {
        try {
            return 0.5 * base * height;
        } catch (Exception e) {
            return 0.0;
        }
    }

    public static String firstChar(String str) {
        try {
            return "" + str.charAt(0);
        } catch (Exception e) {
            return "0";
        }
    }

    public static int roundDouble(double num) {
        try {
            return (int) Math.round(num);
        } catch (Exception e) {
            return 0;
        }
    }

    public static String concatThree(String a, String b, String c) {
        try {
            return a + b + c;
        } catch (Exception e) {
            return "";
        }
    }

    public static boolean isOdd(int num) {
        try {
            return num % 2 != 0;
        } catch (Exception e) {
            return false;
        }
    }

    public static boolean isEmptyString(String str) {
        try {
            return str.trim().isEmpty();
        } catch (Exception e) {
            return true;
        }
    }

    public static boolean isAdult(int age) {
        try {
            return age >= 18;
        } catch (Exception e) {
            return false;
        }
    }

    public static int countDigits(long num) {
        try {
            return String.valueOf(num).length();
        } catch (Exception e) {
            return 0;
        }
    }

    public static String temperatureStatus(double celsius) {
        try {
            return celsius > 30 ? "Hot" : "Normal";
        } catch (Exception e) {
            return "Error";
        }
    }

    public static String simpleEncrypt(String str) {
        try {
            return new StringBuilder(str).reverse().toString();
        } catch (Exception e) {
            return "";
        }
    }

    public static long addLeapSecond(long timestamp) {
        try {
            return timestamp + 1000;
        } catch (Exception e) {
            return 0L;
        }
    }

    public static boolean isBinary(String str) {
        try {
            return str.matches("[01]+");
        } catch (Exception e) {
            return false;
        }
    }

    public static int compareNumbers(double a, double b) {
        try {
            return Double.compare(a, b);
        } catch (Exception e) {
            return 0;
        }
    }

    public static boolean isPrimeShort(int num) {
        try {
            if (num <= 1) return false;
            for (int i = 2; i <= Math.sqrt(num); i++)
                if (num % i == 0) return false;
            return true;
        } catch (Exception e) {
            return false;
        }
    }

    public static String formatDecimal(double num, int places) {
        try {
            return String.format("%." + places + "f", num);
        } catch (Exception e) {
            return "0.00";
        }
    }

    public static int simpleChecksum(String str) {
        try {
            return str.length() % 100;
        } catch (Exception e) {
            return 0;
        }
    }

    public static boolean isWeekend(int dayOfWeek) {
        try {
            return dayOfWeek == 6 || dayOfWeek == 7;
        } catch (Exception e) {
            return false;
        }
    }


    public static double toPercentage(double ratio) {
        try {
            return ratio * 100;
        } catch (Exception e) {
            return 0.0;
        }
    }

    public static boolean randomBoolean(int num) {
        try {
            return Math.random() * 3 < (num % 3);
        } catch (Exception e) {
            return false;
        }
    }
}